<?php defined('IN_PHPCMS') or exit('Access Denied'); ?><?php include template('member','header'); ?>
<script type="text/javascript" src="images/js/validator.js"></script>
<div id="main">
  <?php include template('order' , 'left'); ?>
  <div id="right">
    <p id="position"> <strong>当前位置：</strong><a href="">首页</a><a href="<?php echo $MODULE['member']['url'];?>">会员中心</a><a href="<?php echo $M['url'];?>">订单</a>收货地址</p>

    <table cellpadding="0" cellspacing="1" class="table_list">
      <caption>管理收货地址</caption>
  <tr>
        <th width="60">收货人</th>
        <th width="60">配送区域</th>
        <th width="90">电话</th>
        <th width="90">手机</th>
        <th>地址</th>
        <th width="50">邮编</th>
        <th width="80">操作</th>
  </tr>
<?php if($delivers) { ?>
<?php if(is_array($delivers)) foreach($delivers AS $k => $d) { ?>
 	  <tr>
        <td><?php echo $d['consignee'];?></td>
        <td><?php echo $AREA[$d['areaid']]['name'];?><input type="hidden" name="areaid_<?php echo $d['deliverid'];?>" id="areaid_<?php echo $d['deliverid'];?>" value="<?php echo $d['areaid'];?>"><input type="hidden" name="areaname_<?php echo $d['deliverid'];?>" id="areaname_<?php echo $d['deliverid'];?>" value="<?php echo $AREA[$d['areaid']]['name'];?>"></td>
        <td><?php echo $d['telephone'];?></td>
        <td><?php echo $d['mobile'];?></td>
        <td class="align_l"><?php echo $d['address'];?></td>
        <td><?php echo $d['postcode'];?></td>
        <td><a href="<?php echo $M['url'];?>deliver.php?action=edit&deliverid=<?php echo $d['deliverid'];?>">修改</a> | <a href="javascript:confirmurl('<?php echo $M['url'];?>deliver.php?action=delete&deliverid=<?php echo $d['deliverid'];?>', '删除该地区')">删除</a></td>
  </tr>
<?php } ?>
<?php } ?>
   </table>

<?php if(!$delivers || count($delivers) < $M['maxdelivers']) { ?>
<form action="<?php echo $M['url'];?>deliver.php?action=add" method="post" name="myform" id ="myform">
<table cellpadding="0" cellspacing="1" id="newdeliver" class="table_form">
    <caption>新增收货地址</caption>
  <tr>
        <th width="15%"><font color="red">*</font> 配送区域：</th>
        <td>
            <input type="hidden" name="d[areaid]" id="areaid" value="<?php echo $areaid;?>">
<span id="load_areaid"></span>
<a href="javascript:areaid_reload();">重选</a>
        </td> 
      </tr>
      <tr>
        <th><font color="red">*</font> 收货人：</th>
        <td><input type="text" name="d[consignee]" id="consignee" value="<?php echo $consignee;?>" size="12" require="true" datatype="require" msg="请填写收货人"/></td>       
      </tr>
  <tr>
        <th><font color="red">*</font> 电话：</th>
        <td><input type="text" name="d[telephone]" id="telephone" value="<?php echo $telephone;?>" size="20" require="true" datatype="custom" regexp="^[\d|\-|\+]{3,20}$"  msg="请填写正确的电话" msgid="telephone_notice"/> 格式：010-10000000-801 <span id="telephone_notice"></span></td>     
      </tr>
  <tr>
        <th><font color="red">*</font> 手机：</th>
        <td><input type="text" name="d[mobile]" id="mobile" value="<?php echo $mobile;?>" size="20" require="true" datatype="mobile" msg="请填写正确的手机" msgid="mobile_notice"/> 格式：13800000000 <span id="mobile_notice"></span></td>       
      </tr>
  <tr>
        <th><font color="red">*</font> 地址：</th>
        <td><input type="text" name="d[address]" id="address" value="<?php echo $address;?>" size="60" require="true" datatype="require" msg="填写正确的地址"/></td>       
      </tr>
      <tr>
        <th><font color="red">*</font> 邮编：</th>
        <td><input type="text" name="d[postcode]" id="postcode" value="<?php echo $postcode;?>" size="8" require="true" datatype="zip" msg="填写正确的邮编" msgid="postcode_notice"/> 格式：100000 <span id="postcode_notice"></span></td>       
      </tr>
      <tr>
        <th></th>
        <td><input type="submit" name="dosubmit" value=" 确定 "/> <input type="reset" name="reset" value=" 重置 "/> 最多保存<?php echo $M['maxdelivers'];?>个有效地址</td>       
      </tr>
</table>
</form>	
<?php } ?>
  </div>
</div>
<div class="clear"></div>
<?php include template('phpcms','footer'); ?>
<script language="javascript" type="text/javascript">
$().ready(function() {
  $('form').checkForm(1);
});

function areaid_load(id)
{
$.get("load.php", { field: 'areaid', id: id }, function(data){
$('#load_areaid').append(data);
});
}

function areaid_reload()
{
$('#load_areaid').html('');
areaid_load(0);
}
areaid_reload();
</script>